package csc.daonjpa.java.domain;

import java.io.Serializable;
import java.util.List;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.validator.constraints.NotEmpty;

/**
 * Entity class for Account table. This is a simple POJO class with annotations to define mapping with DB table
 * @author nvu3
 *
 */
@Entity
@Table( name = "Account")
@AttributeOverrides({
	@AttributeOverride(name = "availableAmount", column=@Column(name = "availableAmount"))
})
public class Account extends BaseInfo implements Serializable {
	private static final long serialVersionUID = 1L;
	
	@NotEmpty
	@Column(name = "accountName")
	private String accountName;
	
	@NotEmpty
	@Column(name = "accountType")
	private String accountType;
	
	@NotEmpty
	@ManyToOne
	@JoinColumn(name = "loginId")
	private Customer customer;
	
	@OneToOne (mappedBy = "account")
	private TagetAccount tagetAccount;
	
	@OneToOne (mappedBy = "receiveAccount")
	private LogTransaction receiveAccount;
	
	@OneToMany (mappedBy = "sendAccount")
	private List<LogTransaction> sendAccounts;

	/**
	 * Required constructor
	 */
	public Account() {
	
	}
	
	/**
	 * Other constructor, you can define as many constructors as you want, but the constructor without parameters is required
	 * @param Id
	 * @param accountName
	 * @param accountType
	 */
	public Account(Long Id, String accountName, String accountType, String number, Long availableAmount) {
		super(Id, number, availableAmount);
		this.accountName = accountName;
		this.accountType = accountType;
	}
	

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	/**
	 * @return AccountName
	 */
	public String getAccountName() {
		return this.accountName;
	}

	/**
	 * Set accountName
	 * @param accountName
	 */
	public void setAccountName(String accountName) {
		this.accountName = accountName;
	}

	/**
	 * @return AccountType
	 */
	public String getAccountType() {
		return this.accountType;
	}

	/**
	 * Set accountType
	 * @param accountType
	 */
	public void setAccountType(String accountType) {
		this.accountType = accountType;
	}
}